package com.iflytek.iot.redis.util;

/**
 * @author yu 2019/10/1.
 */
public class RedisUtils {

    /**
     * 例如：
     * RedisUtils.getRedisPipeText("hmset","usr"+i,"userid","usr"+i,"username","usrname"+i)
     * 生成redis批量导入文本，生成后使用redis-cli --pipe命令导入
     * @param args
     * @return
     */
    public static String getRedisPipeText(String... args){
        StringBuilder sb = new StringBuilder();
        sb.append("*").append(args.length).append("\r\n");
        for(String arg : args){
            sb.append("$").append(arg.length()).append("\r\n");
            sb.append(arg).append("\r\n");
        }
        return sb.toString();
    }
}
